package com.heeexy.example.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.heeexy.example.dao.BoardDao;
import com.heeexy.example.service.BoardService;
import com.heeexy.example.util.CommonUtil;
@Service
public class BoardServiceImpl implements BoardService {
	  @Autowired
	    private BoardDao boardDao;

	@Override
	public JSONObject addBoard(JSONObject jsonObject) {
		boardDao.insert(jsonObject);
		 return CommonUtil.successJson();
	}

	@Override
	public JSONObject listBoard(JSONObject jsonObject) {
		CommonUtil.fillPageParam(jsonObject);
        int count = boardDao.count(jsonObject);
        List<JSONObject> list =  boardDao.listBoard(jsonObject);
        return CommonUtil.successPage(jsonObject, list, count);
	}

	@Override
	public JSONObject deleteBoard(JSONObject jsonObject) {
		boardDao.delete(jsonObject);
        return CommonUtil.successJson();
	}

}
